<template>
	<view class="main">
		<!--list start-->
		<view class="master-infoTiele">
			<view class="master-item">
				<view class="master-faceItem poser dis-row">
					<!--头像处理start-->
					<view class="faceItem-ico">
						<image :src="cardinfo.avatar?cardinfo.avatar:'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/1.jpg'"></image>
					</view>
					<!--头像处理over-->
					<!--顶部右侧标题文字开始-->
					<view class="faceText dis-clm">
						<!--置顶信息start-->
						<view class="faceText-t1 dis-row">
							<view class="master-name">{{cardinfo.nickName}}</view>
							<label v-if="cardinfo.realName"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/user-real.svg"></image></label>
							<text v-if="cardinfo.realName">实名认证</text>
						</view>
						<!--置顶信息over-->
						<view class="master-userinfo dis-row">
							{{cardinfo.gender==1?'男':'女'}}<text>|</text>{{cardinfo.age}}岁<text>|</text>{{cardinfo.nationStr}}
						</view>
					</view>
					<!--顶部右侧标题文字结束-->
					<!--是否在线开始-->
					<!-- <view class="const-an">随时进场</view> -->
					<view class="const-an" v-if="cardinfo.status!=null"><text v-if="cardinfo.status==0">找活中</text>
					<text v-if="cardinfo.status==1">暂不找活</text>
					<text v-if="cardinfo.status==2">有活预定下一个</text></view>
					<!--是否在线结束-->
				</view>
				<!--标签列表开始-->
			    <view class="contacts-gouceng dis-row" @click="contactsNav">
					<label>人员构成</label><text>{{cardinfo.staffTypeStr?cardinfo.staffTypeStr:''}}({{cardinfo.peopleNumStr?cardinfo.peopleNumStr:0}}人)</text>
					<label>工龄</label><text>{{cardinfo.workYear?cardinfo.workYear+'年':'未填'}}</text>
					<label>熟练度</label><text>{{cardinfo.masteryStr?cardinfo.masteryStr:'..'}}</text>
				</view>
				<!--标签列表结束-->
		<!-- 	   <view class="button-v1 dis-row">
			   	<view class="map-ico"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/ico-address.svg"></image></view>
			   	<view class="bt-s dis-row">
			   		<label>陕西西安</label><text>·</text><label>01-20 19:00:00</label>
			   	</view>
			   </view> -->
			   <view class="contacts-address dis-row poser">
				   <view class="map-ico"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/ico-address.svg"></image></view>
				   <view class="bt-s dis-row">
				   	<label>陕西西安</label><text>·</text><label>{{cardinfo.updateTime}}</label>
				   </view>
				  <!-- <view class="cnt-ico dis-row">
					   <view><label></label></view><text>今日找活中</text>
				   </view> -->
				   <view v-if="cardinfo.status" class="cnt-ico dis-row">
				   		<view><label></label></view><text>今日找活中</text>
				   </view>
			   </view>
			</view>
		</view>
		<!--list over-->
		<!--找活期望开始-->
		<view class="cons-infoname v-box dis-clm">
			<view class="t-name">找活期望</view>
			<view class="t-text dis-row" v-if="cardinfo.skills">
				<label>工种</label><text>{{cardinfo.skills?cardinfo.skills:''}}</text>
			</view>
			<view class="t-text dis-row" v-if="cardinfo.hopeAddr">
				<label>期望地点</label><text>{{cardinfo.hopeAddr?cardinfo.hopeAddr:''}}</text>
			</view>
			<view class="t-text dis-row" v-if="cardinfo.workType1Str">
				<label>长短工</label><text>{{cardinfo.workType1Str?cardinfo.workType1Str:''}}</text>
			</view>
			<view class="t-text dis-row" v-if="cardinfo.settlementStr">
				<label>结算方式</label>
				<!-- <text>{{cardinfo.settlementStr?cardinfo.settlementStr:''}} / 8000元/月</text> -->
				<text v-if="cardinfo.settlementStr">{{cardinfo.settlementStr}}</text>
				<text v-if="cardinfo.salary"> /{{cardinfo.salary}}</text>
				<text v-if="cardinfo.salaryUnitStr">{{cardinfo.salaryUnitStr}}</text>
			</view>
			<view class="t-textPre">
				{{cardinfo.notice?cardinfo.notice:''}}
			</view>
			<block v-if="cardinfo.videoUrl">
			<view class="t-name">视频简历</view>
			<view class="t-video">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/1.jpg"></image>
			</view>
			</block>
			<block v-if="cardinfo.productHistoryList&&cardinfo.productHistoryList.length>0">
				<view class="t-name">项目经历</view>
				<view class="tx-jingli v-box dis-clm" v-for="(item,index) in cardinfo.productHistoryList" :key="index">
					<view class="jingli-name">{{item.enterpriseName}}</view>
					<view class="jingli-pre dis-row">
						<label>{{item.skill}}</label>
						<text>{{item.startTime}}-{{item.endTime}}</text>
					</view>
					<view class="jingli-info">{{item.remark}}</view>
				</view>
			</block>
			<block v-if="cardinfo.certificateInfoList">
				<view class="t-name" style="margin-bottom: 20rpx;">技能证书</view>
				<view class="contacts-zhengshu dis-row" v-for="(item,index) in cardinfo.certificateInfoList" :key="index">
					<image :src="item.imgUrl"></image>
					<view class="zhengshu-text dis-clm">
						<label class="child-label">{{item.cname}}</label>
						<view class="dis-row">
							<label>获得证书时间</label><text>{{item.issueDate}}</text>
						</view>
					</view>
				</view>
			</block>
		</view>
		<view style="height: 250rpx;"></view>
		<!--找活期望结束-->
		<view class="constacts-footer">
			<view class="footer-con dis-row">
				<view class="ft-v1 dis-clm" @click="conDel">
					<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/contacts-del.png"></image>
					<text>删除</text>
				</view>
				<view class="ft-v1 dis-clm" @click="conBeizhu">
					<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/ico-beizhu.svg"></image>
					<text>备注</text>
				</view>
				<view class="ft-btn ft-pingjia" @click="checkperson">评价</view>
				<view class="ft-btn ft-goutong" @click="goutong">立即沟通</view>
			</view>
		</view>
		<!--删除pop-->
		<pop ref="del" :direction="direction" :is_close="true" :is_mask="true" :width="90">
	         <view class="con-del dis-clm">
				 <view class="condel-ico"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/contacts-del.svg"></image></view>
				 <view class="condel-text">确定删除此名片？</view>
				 <view class="condel-btn condel-sure" @click="sureDel">删除</view>
				 <view class="condel-btn condel-con" @click="delCon">取消</view>
			 </view>
		</pop>
		<!--修改备注-->
		<pop ref="beizhu" :direction="direction" :is_close="true" :is_mask="true" :width="90">
		     <view class="con-del dis-clm">
				 <view class="condel-ico sborder"><image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/my/ico-beizhu.svg"></image></view>
				 <view class="con-form dis-clm">
					 <label>修改备注</label>
					 <input type="text" v-model="inputName" placeholder="请输入备注信息"/>
				 </view>
				 <view class="condel-btn condel-blue" @click="nodesureDel">确定</view>
				 <view class="condel-btn condel-con" @click="nodedelCon">取消</view>
			 </view>
		</pop>
		
		<!--熟练度-->
		<pop ref="mastery" direction="below" :is_close="true" :is_mask="true" :width="100">
			<view class="popOption">
				<view class="title">请对此人做出评价</view>
				<view class="option">
					<view
						v-for="(uv,ui) in levelList" 
						:key="ui" 
						:class="{'active':levelId === uv.id}" 
						@click="personChange(uv)">{{uv.name}}</view>
				</view>
				<view class="define">
					<view @click="personDefine()">确定</view>
				</view>
			</view>
		</pop>
	</view>
</template>

<script>
import pop from "@/components/ming-pop/ming-blow.vue"
import Index from "@/common/index-model.js"
let index = new Index()
let that = null
export default {
	data() {
		return {
			direction:"center",
			cardinfo:{},
			oldid:'',
			inputName:'',
			levelList:[],
			levelId:0,
			userid:"",
			user1:'',
			user2:'',
		}
	},
	components: {
		pop
	},
	methods: {
		goutong() {
			let url='../../pagesB/hxIm/index?user='+this.cardinfo.hxName
			index.navigate_to(url)
		},
		conDel() {
			this.$refs.del.show();
		},
		checkperson(){
			this.getPersonList();
			this.$refs.mastery.show();
		},
		personChange(item){
			this.levelId=item.id;
		},
		personDefine(){
			let url="/client/public/add/people"
			index.getPublicUserMember({targetId:this.user1.id,tindex:this.levelId},url,'POST',res=>{
				if(res.data.code==200){
					index.show_tips('评价成功！');
					setTimeout(()=>{
						index.redirectto('./contacts')
					},500)
				}else{
					index.show_tips('评价失败，请稍后重试！');
				}
			})
			this.$refs.mastery.close();
		},
		//获取人员构成
		getPersonList() {
			index.getPublicUserMember({},'/client/public/find/evaluate/people','get',res=>{
				if(res.data.code == 200 && res.data.success){
					this.levelList=res.data.result;
				}
			})
		},
		getUserInfo(){
			let url="/client/public/query/user"
			index.getPublicUserMember([this.toUser,uni.getStorageSync('hxuser')],url,'post',res=>{
				if(res.data.code==200){
					let userlist=res.data.result;
					const user1 = userlist.filter(
					    (item) => item.hx_name == this.toUser
					);
					const user2 = userlist.filter(
					    (item) => item.hx_name == uni.getStorageSync('hxuser')
					);
					// let userc1=user1[0];
					// userc1.avatar=userc1.avatar?userc1.avatar:'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png';
					// let userc2=user2[0];
					// userc2.avatar=userc2.avatar?userc2.avatar:'http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/default-avatar.png';
					// this.user1=userc1;
					// this.user2=userc2;
				}
			})
		},
		sureDel() {
			if(this.oldid){
				let url ="client/collectCard/remove/"+this.oldid
				index.getPublicUserMember({},url,'post',res=>{
					if(res.data.code == 200 && res.data.success){
						index.show_tips('删除名片成功')
						setTimeout(()=>{
							index.redirectto('./contacts')
						},500)
					}else{
						index.show_tips(res.data.message)
						return false
					}
				})
			}
			this.$refs.del.close()
		},
		nodesureDel() {
			if(this.inputName == ''){
				index.show_tips('请添加备注')
				return false
			}
			let send = {
				"id":this.oldid,
				"note":this.inputName
			}
			index.getPublicUserMember(send,'client/collectCard/modify','post',res=>{
				if(res.data.code == 200 && res.data.success){
					index.show_tips('备注添加成功')
					setTimeout(()=>{
						index.redirectto('./contacts')
					},500)
				}else{
					index.show_tips(res.data.message)
					return false
				}
			})
			this.$refs.beizhu.close()
		},
		delCon() {
			this.$refs.del.close()
		},
		conBeizhu() {
			this.$refs.beizhu.show()
		},
		getList(id) {
			let url="client/card/detail/"+id
			index.getPublicUserMember({},url,'get',res=>{
				if(res.data.code == 200 && res.data.success){
					this.cardinfo = res.data.result
				}else{
					this.cardinfo={}
				}
			})
		}
	},
	onLoad(opt) {
		this.oldid = opt.id
		this.getList(opt.id)
		this.getUserInfo()
	}
}
</script>

<style>
@import url("@/static/css/publics.css");
@import url("@/static/css/mybrowse.css");
@import url("@/static/css/myBeInterested.css");	
@import url("@/static/css/mycontacts.css");
page{
	width: 100%;height: 100%;background-color: #ffffff;
}
/* .main{width: 100%;height: 100%;position: relative;} */
.popOption{
	padding: 20rpx;
}
.popOption .title{ text-align: center; font-size: 36rpx; color: #3D3D3D; font-weight: bold;}
.popOption .option{ margin-top: 32rpx;}
.popOption .option view{ height: 88rpx; line-height: 88rpx; text-align: center;}
.popOption .option view.active{ color: #0575FF;}
.popOption .define{ margin-top: 32rpx; }
.popOption .define view{ height: 88rpx; line-height: 88rpx; color: #0575FF; text-align: center;}
</style>